<template>
  <div>
    <dialog-edit :visible.sync="dialogVisible" :title="'角色'" :editModel="editModel" :api="api" :form="form"
      :formRules="formRules" @onSave="onSave">
      <dym-form :editModel="editModel" :componentList="componentList" :formValue.sync="form"
        ></dym-form>
    </dialog-edit>
  </div>
</template>

<script>
  import BaseDialog from '@/pages/BaseDialog'
  import DialogEdit from '@/components/dialog/DialogEdit'
  import dymForm from '@/components/element/dymForm'
  export default {
    extends: new BaseDialog(),
    components: {
      DialogEdit,
      dymForm
    },
    data () {
      return {
        // 需要显示的每一项定义在这里
        componentList: [
          {
            label: '角色名称',
            prop: 'name',
            labelWidth: '120px',
            componentName: 'el-input',
            cols: [12, 12, 12, 12],
            placeholder: '请输入',
            value: 'name'
          },
          {
            label: '角色编码',
            prop: 'enname',
            labelWidth: '120px',
            componentName: 'el-input',
            cols: [12, 12, 12, 12],
            placeholder: '请输入',
            value: 'enname'
          },
          {
            label: '状态',
            prop: 'useable',
            labelWidth: '120px',
            componentName: 'dict',
            dictTypeCode: 'useable',
            cols: [12, 12, 12, 12],
            placeholder: '请输入',
            value: 'useable'
          },
          {
            label: '备注',
            prop: 'remarks',
            labelWidth: '120px',
            componentName: 'el-input',
            type: 'textarea',
            cols: [24, 24, 24, 24],
            placeholder: '请输入',
            value: 'remarks'
          }
        ],
        // 表单验证
        formRules: {
          // 表单字段名：[规则]
          name: [{ required: true, message: '必填', trigger: 'blur' }],
          enname: [{ required: true, message: '必填', trigger: 'blur' }],
          useable: [{ required: true, message: '必填', trigger: 'change' }]
        }
      }
    },
    created () {
      if (this.editModel === 'C') {
        this.$set(this.form, 'useable', '1')
      }
    }
  }
</script>
